/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * funcionarioPNovo.java
 *
 * Created on 10/11/2010, 11:19:41
 */

/**
 *
 * @author Caio
 */
package gui.funcionarios;
import ge.usuarios.Funcionario;

import ge.util.Data;
import ge.util.Validadores;
import gui.GerenciadorDeJanelas;
import gui.MenuCadastra;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.border.BevelBorder;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AlteraProfessor extends javax.swing.JPanel {
	private javax.swing.JLabel c1;
    private javax.swing.JLabel c2;
    private javax.swing.JLabel c3;
    private javax.swing.JLabel c4;
    private javax.swing.JLabel c5;
    private javax.swing.JLabel c6;
    private javax.swing.JLabel c7;
    private javax.swing.JLabel c9;
    private javax.swing.JButton cadastra;
    private JTextField caixaCpf4;
    private javax.swing.JTextField caixaAdm;
    private JTextField caixaCpf3;
    private javax.swing.JTextField caixaEnd;
    private javax.swing.JTextField caixaFoto;
    private javax.swing.JTextField caixaMail;
    private javax.swing.JTextField caixaNome;
    private JTextField caixaCpf2;
    private javax.swing.JTextField caixaPosse;
    private javax.swing.JButton cancelar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JButton limpar;
    private boolean flag = true;
    private String nome;
	private int matricula;
	private String cpf;
	private String cpf1;
	private String cpf2;
	private String cpf3;
	private JButton removeProfessor;
	private JTextField caixaPosse3;
	private JTextField caixaPosse2;
	private JTextField caixaAdm3;
	private JTextField caixaAdm2;
	private JButton DisciplinasEHorarios;
	private JButton addFoto;
	private JTextField caixaTel1;
	private JTextField caixaCpf;
	private JTextField caixaTel3;
	private JTextField caixaTel2;
	private String cpf4;
	private String endereco;
	private Data dataAdmissao;
    private String diaAdm;
    private String mesAdm;
    private String anoAdm;
    private Data dataPosse;
    private String diaPosse;
    private String mesPosse;
    private String anoPosse;
	private String telefone1;
	private String telefone2;
	private String telefone3;
	private String email;
	private ArrayList<Integer> listaMatriculas = new ArrayList();
	private Validadores valida = new Validadores();
	private String foto;
	private String cargo;
	private String telefone;
	private List<Integer> todasMatriculas;
	Color verde = new Color(0,150,0);
	
    /** Creates new form funcionarioPNovo */
    public AlteraProfessor() {
        initComponents();
        	
        	caixaNome.setText(SelecionaFuncionario.professor.getNome());
        	caixaEnd.setText(SelecionaFuncionario.professor.getEndereco());
        	caixaMail.setText(SelecionaFuncionario.professor.getEmail());
        	
        	caixaAdm.setText(SelecionaFuncionario.professor.getDataAdmissao().toString());
        	caixaPosse.setText(SelecionaFuncionario.professor.getDataPosse().toString());
        
        	caixaFoto.setText(SelecionaFuncionario.professor.getFoto());
        	
        	caixaCpf.setText(SelecionaFuncionario.professor.fragmentaCpf()[0]);
        	caixaCpf2.setText(SelecionaFuncionario.professor.fragmentaCpf()[1]);
        	caixaCpf3.setText(SelecionaFuncionario.professor.fragmentaCpf()[2]);
        	caixaCpf4.setText(SelecionaFuncionario.professor.fragmentaCpf()[3]);
        	caixaTel1.setText(SelecionaFuncionario.professor.fragmentaTelefone()[0]);
        	caixaTel2.setText(SelecionaFuncionario.professor.fragmentaTelefone()[1]);
        	caixaTel3.setText(SelecionaFuncionario.professor.fragmentaTelefone()[2]);
        	caixaAdm.setText(SelecionaFuncionario.professor.getDataAdmissao().fragmentaData()[0]);
        	caixaAdm2.setText(SelecionaFuncionario.professor.getDataAdmissao().fragmentaData()[1]);
        	caixaAdm3.setText(SelecionaFuncionario.professor.getDataAdmissao().fragmentaData()[2]);
        	caixaPosse.setText(SelecionaFuncionario.professor.getDataPosse().fragmentaData()[0]);
        	caixaPosse2.setText(SelecionaFuncionario.professor.getDataPosse().fragmentaData()[1]);
        	caixaPosse3.setText(SelecionaFuncionario.professor.getDataPosse().fragmentaData()[2]);
        	telefone1 = caixaTel1.getText();
        	telefone2 = caixaTel2.getText();
        	telefone3 = caixaTel3.getText();
        	
        	cpf1 = caixaCpf.getText();
        	cpf2 = caixaCpf2.getText();
        	cpf3 = caixaCpf3.getText();
        	
        	diaAdm = caixaAdm.getText();
        	mesAdm = caixaAdm2.getText();
        	anoAdm = caixaAdm3.getText();
        	
        	diaPosse = caixaPosse.getText();
        	mesPosse = caixaPosse2.getText();
        	anoPosse = caixaPosse3.getText();
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        caixaNome = new javax.swing.JTextField();
        caixaNome.setFont(new java.awt.Font("Tahoma",0,18));
        caixaEnd = new javax.swing.JTextField();
        caixaEnd.setFont(new java.awt.Font("Tahoma",0,18));
        caixaMail = new javax.swing.JTextField();
        caixaMail.setFont(new java.awt.Font("Tahoma",0,18));
        caixaAdm = new javax.swing.JTextField();
        caixaAdm.setFont(new java.awt.Font("Tahoma",0,18));
        caixaPosse = new javax.swing.JTextField();
        caixaPosse.setFont(new java.awt.Font("Tahoma",0,18));
        caixaFoto = new javax.swing.JTextField();
        caixaFoto.setFont(new java.awt.Font("Tahoma",0,18));
        GroupLayout layout = new GroupLayout((JComponent)this);
        this.setLayout(layout);
        jLabel11 = new javax.swing.JLabel();
        cancelar = new javax.swing.JButton();
        limpar = new javax.swing.JButton();
        this.setSize(800, 600);
        this.setBackground(new java.awt.Color(204,204,255));
        cadastra = new javax.swing.JButton();
        c1 = new javax.swing.JLabel();
        c2 = new javax.swing.JLabel();
        c3 = new javax.swing.JLabel();
        c4 = new javax.swing.JLabel();
        c5 = new javax.swing.JLabel();
        c7 = new javax.swing.JLabel();
        c9 = new javax.swing.JLabel();
        c6 = new javax.swing.JLabel();

        jLabel1.setFont(new java.awt.Font("Arial",0,24));
        jLabel1.setText("Nome do Funcionario: ");
        jLabel1.setForeground(new java.awt.Color(0,102,102));

        jLabel2.setFont(new java.awt.Font("Arial",0,24));
        jLabel2.setText("Numero do cpf: ");
        jLabel2.setForeground(new java.awt.Color(0,102,102));

        jLabel3.setFont(new java.awt.Font("Arial",0,24));
        jLabel3.setText("Endereco:");
        jLabel3.setForeground(new java.awt.Color(0,102,102));

        jLabel4.setFont(new java.awt.Font("Arial",0,24));
        jLabel4.setText("Numero do telefone: ");
        jLabel4.setForeground(new java.awt.Color(0,102,102));

        jLabel5.setFont(new java.awt.Font("Arial",0,24));
        jLabel5.setText("Digite o email:");
        jLabel5.setForeground(new java.awt.Color(0,102,102));

        jLabel8.setFont(new java.awt.Font("Arial",0,24));
        jLabel8.setText("Data de posse:");
        jLabel8.setForeground(new java.awt.Color(0,102,102));

        jLabel6.setFont(new java.awt.Font("Arial",0,24));
        jLabel6.setText("Data de admissao:");
        jLabel6.setForeground(new java.awt.Color(0,102,102));

        jLabel9.setFont(new java.awt.Font("Arial",0,24));
        jLabel9.setText("Caminho da foto:");
        jLabel9.setForeground(new java.awt.Color(0,102,102));

        caixaNome.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaNomeKeyReleased(evt);
            }
        });

        caixaEnd.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaEndKeyReleased(evt);
            }
        });

        caixaMail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaMailKeyReleased(evt);
            }
        });

        caixaAdm.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                try {
					caixaAdmKeyReleased(evt);
				} catch (Exception e) {
					
					e.printStackTrace();
				}
            }
        });

        caixaPosse.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                try {
					caixaPosseKeyReleased(evt);
				} catch (Exception e) {
					
					e.printStackTrace();
				}
            }
        });

        caixaFoto.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                caixaFotoKeyReleased(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Arial",0,36)); // NOI18N
        jLabel11.setText("Alterar dados do professor");
        jLabel11.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        jLabel11.setForeground(new java.awt.Color(0,102,102));
        {
        	removeProfessor = new JButton();
        	removeProfessor.setText("Remover Professor");
        	removeProfessor.setBackground(new java.awt.Color(255,255,255));
        	removeProfessor.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			int matricula = SelecionaFuncionario.professor.getMatricula();
        			for(int i = 0; i < GerenciadorDeJanelas.todosProfessores.size(); i++){
        				if(GerenciadorDeJanelas.todosProfessores.get(i).getMatricula() == SelecionaFuncionario.professor.getMatricula()){
        					
        					GerenciadorDeJanelas.todosProfessores.remove(i);
        					
        				}
        				
        			}
        			for(int j = 0; j < GerenciadorDeJanelas.todasMatriculas.size(); j++){
        				if(GerenciadorDeJanelas.todasMatriculas.get(j) == matricula){
        					GerenciadorDeJanelas.todasMatriculas.remove(j);
        				}
        			}
        			// transforma em xml
        			   String xmlProfessor = GerenciadorDeJanelas.ARQUIVADOR
        				.toXML(GerenciadorDeJanelas.todosProfessores);
        			   String xmlMatriculas = GerenciadorDeJanelas.ARQUIVADOR.toXML(GerenciadorDeJanelas.todasMatriculas);
        			// grava o arrayXml no arquivo
        				GerenciadorDeJanelas.gravar(GerenciadorDeJanelas.arquivoDeProfessores,
        						xmlProfessor);
        				GerenciadorDeJanelas.gravar(GerenciadorDeJanelas.arquivoDeMatriculas,
        						xmlMatriculas);
        			limparMouseClicked(evt);
        		    SelecionaFuncionario selecF = new SelecionaFuncionario();
        		    GerenciadorDeJanelas.window.setContentPane(selecF);
        		    GerenciadorDeJanelas.window.setVisible(true);
        		}
        	});
        }
        {
        	caixaAdm2 = new JTextField();
        	caixaAdm2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaAdm2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaAdm2KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaAdm3 = new JTextField();
        	caixaAdm3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaAdm3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaAdm3KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaPosse2 = new JTextField();
        	caixaPosse2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaPosse2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaPosse2KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	caixaPosse3 = new JTextField();
        	caixaPosse3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaPosse3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			try {
        				caixaPosse3KeyReleased(evt);
        			} catch (Exception e) {
        				
        				e.printStackTrace();
        			}
        		}
        	});
        }
        {
        	DisciplinasEHorarios = new JButton();
        	DisciplinasEHorarios.setText("Disciplinas e Horarios");
        	DisciplinasEHorarios.setForeground(new java.awt.Color(0,0,0));
        	DisciplinasEHorarios.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        	DisciplinasEHorarios.setBackground(new java.awt.Color(255,255,255));
        	DisciplinasEHorarios.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			DisciplinasEHorarios disc = new DisciplinasEHorarios();
        			GerenciadorDeJanelas.window.setContentPane(disc);
        			GerenciadorDeJanelas.window.setVisible(true);
        		}
        	});
        }
        {
        	addFoto = new JButton();
        	addFoto.setText("Adiciona Foto");
        	addFoto.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        	addFoto.setBackground(new java.awt.Color(255,255,255));
        	addFoto.addMouseListener(new MouseAdapter() {
        		public void mouseClicked(MouseEvent evt) {
        			FotoPanel adFoto = new FotoPanel();
        			caixaFoto.setText(adFoto.retornaCaminho());
        			foto = adFoto.retornaCaminho();
        			c9.setText("OK");
        			c9.setForeground(Color.GREEN);
        			
        		}
        	});
        }
        {
        	caixaTel1 = new JTextField();
        	caixaTel1.setText(null);
        	caixaTel1.setBackground(Color.WHITE);
        	caixaTel1.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel1.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel1KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaCpf = new JTextField();
        	caixaCpf.setText(null);
        	caixaCpf.setBackground(Color.WHITE);
        	caixaCpf.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpfKeyReleased(evt);
        		}
        	});
        }
        {
        	caixaTel2 = new JTextField();
        	caixaTel2.setText(null);
        	caixaTel2.setBackground(Color.WHITE);
        	caixaTel2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel2KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaTel3 = new JTextField();
        	caixaTel3.setText(null);
        	caixaTel3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaTel3.setBackground(Color.WHITE);
        	caixaTel3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaTel3KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaCpf3 = new JTextField();
        	caixaCpf3.setText(null);
        	caixaCpf3.setBackground(Color.WHITE);
        	caixaCpf3.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf3.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf3KeyReleased(evt);
        		}
        	});
        }
        {
        	caixaCpf2 = new JTextField();
        	caixaCpf2.setText(null);
        	caixaCpf2.setBackground(Color.WHITE);
        	caixaCpf2.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf2.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf2KeyReleased(evt);
        		}
        	});
        }

        {
        	caixaCpf4 = new JTextField();
        	caixaCpf4.setText(null);
        	caixaCpf4.setBackground(Color.WHITE);
        	caixaCpf4.setFont(new java.awt.Font("Tahoma",0,18));
        	caixaCpf4.addKeyListener(new KeyAdapter() {
        		public void keyReleased(KeyEvent evt) {
        			caixaCpf4KeyReleased(evt);
        		}
        	});
        }

        cancelar.setText("Cancelar");
        cancelar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        cancelar.setBackground(new java.awt.Color(255,255,255));
        cancelar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                cancelarMouseClicked(evt);
            }
        });

        limpar.setText("Limpar");
        limpar.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        limpar.setBackground(new java.awt.Color(255,255,255));
        limpar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                limparMouseClicked(evt);
            }
        });

        cadastra.setText("Cadastrar");
        cadastra.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        cadastra.setBackground(new java.awt.Color(255,255,255));
        layout.setVerticalGroup(layout.createSequentialGroup()
        	.addContainerGap(19, 19)
        	.addComponent(jLabel11, GroupLayout.PREFERRED_SIZE, 58, GroupLayout.PREFERRED_SIZE)
        	.addGap(46)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c1, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
        	        .addGap(8))
        	    .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 32, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaNome, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c2, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
        	        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	    .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaCpf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addGap(17)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c3, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
        	        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	    .addComponent(jLabel3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaEnd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c4, GroupLayout.PREFERRED_SIZE, 25, GroupLayout.PREFERRED_SIZE)
        	        .addGap(13))
        	    .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
        	    .addGroup(layout.createSequentialGroup()
        	        .addGap(7)
        	        .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	            .addComponent(caixaTel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	            .addComponent(caixaTel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	            .addComponent(caixaTel3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(jLabel5, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(c5, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaMail, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c6, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        	        .addGap(7))
        	    .addComponent(caixaAdm, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(jLabel6, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaAdm2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaAdm3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(jLabel8, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(c7, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(caixaPosse3, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
        	.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(c9, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
        	        .addGap(14))
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(caixaFoto, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
        	        .addGap(6))
        	    .addComponent(jLabel9, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE))
        	.addGap(70)
        	.addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
        	    .addComponent(cadastra, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(limpar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(cancelar, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(addFoto, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(DisciplinasEHorarios, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
        	    .addComponent(removeProfessor, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE))
        	.addContainerGap(57, 57));
        layout.setHorizontalGroup(layout.createSequentialGroup()
        	.addContainerGap()
        	.addGroup(layout.createParallelGroup()
        	    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	        .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	        .addGap(9)
        	        .addGroup(layout.createParallelGroup()
        	            .addGroup(layout.createSequentialGroup()
        	                .addGroup(layout.createParallelGroup()
        	                    .addComponent(caixaFoto, GroupLayout.Alignment.LEADING, 0, 444, Short.MAX_VALUE)
        	                    .addComponent(caixaMail, GroupLayout.Alignment.LEADING, 0, 444, Short.MAX_VALUE)
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(caixaEnd, GroupLayout.PREFERRED_SIZE, 428, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(0, 16, Short.MAX_VALUE))
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(caixaNome, GroupLayout.PREFERRED_SIZE, 428, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(0, 16, Short.MAX_VALUE)))
        	                .addGap(7)
        	                .addGroup(layout.createParallelGroup()
        	                    .addComponent(c9, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                    .addComponent(c5, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                    .addComponent(c3, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                    .addComponent(c1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)))
        	            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                .addGroup(layout.createParallelGroup()
        	                    .addComponent(caixaCpf, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(caixaPosse, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(10))
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(caixaAdm, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(10))
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(caixaTel1, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(21)))
        	                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	                .addGroup(layout.createParallelGroup()
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(addFoto, GroupLayout.PREFERRED_SIZE, 137, GroupLayout.PREFERRED_SIZE)
        	                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	                        .addGroup(layout.createParallelGroup()
        	                            .addComponent(cadastra, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(c7, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(c6, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(c4, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))
        	                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED, 1, Short.MAX_VALUE)
        	                        .addComponent(limpar, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE))
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addGroup(layout.createParallelGroup()
        	                            .addGroup(layout.createSequentialGroup()
        	                                .addPreferredGap(addFoto, caixaPosse2, LayoutStyle.ComponentPlacement.INDENT)
        	                                .addGroup(layout.createParallelGroup()
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addComponent(caixaPosse2, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
        	                                        .addGap(22))
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addComponent(caixaAdm2, GroupLayout.PREFERRED_SIZE, 45, GroupLayout.PREFERRED_SIZE)
        	                                        .addGap(22))
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addPreferredGap(caixaPosse2, caixaCpf2, LayoutStyle.ComponentPlacement.INDENT)
        	                                        .addComponent(caixaCpf2, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE))))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(caixaTel2, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(24)))
        	                        .addGroup(layout.createParallelGroup()
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(caixaPosse3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(24))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(caixaAdm3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(24))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(caixaTel3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(24))
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addGap(24)
        	                                .addComponent(caixaCpf3, GroupLayout.PREFERRED_SIZE, 55, GroupLayout.PREFERRED_SIZE)))
        	                        .addGap(16)
        	                        .addComponent(caixaCpf4, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE)
        	                        .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	                        .addComponent(c2, GroupLayout.PREFERRED_SIZE, 95, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(0, 34, Short.MAX_VALUE)))
        	                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
        	                .addComponent(cancelar, GroupLayout.PREFERRED_SIZE, 99, GroupLayout.PREFERRED_SIZE)
        	                .addGap(26))))
        	    .addGroup(layout.createSequentialGroup()
        	        .addPreferredGap(jLabel1, jLabel4, LayoutStyle.ComponentPlacement.INDENT)
        	        .addGroup(layout.createParallelGroup()
        	            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                .addComponent(jLabel4, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                .addGap(0, 392, Short.MAX_VALUE))
        	            .addGroup(layout.createSequentialGroup()
        	                .addGap(26)
        	                .addGroup(layout.createParallelGroup()
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(removeProfessor, 0, 129, Short.MAX_VALUE)
        	                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
        	                        .addGroup(layout.createParallelGroup()
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(DisciplinasEHorarios, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
        	                                .addGap(327))
        	                            .addComponent(jLabel11, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 458, GroupLayout.PREFERRED_SIZE)))
        	                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                        .addComponent(jLabel6, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                        .addGap(0, 392, Short.MAX_VALUE))
        	                    .addGroup(layout.createSequentialGroup()
        	                        .addPreferredGap(removeProfessor, jLabel9, LayoutStyle.ComponentPlacement.INDENT)
        	                        .addGroup(layout.createParallelGroup()
        	                            .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                .addComponent(jLabel9, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                            .addGroup(layout.createSequentialGroup()
        	                                .addPreferredGap(jLabel9, jLabel2, LayoutStyle.ComponentPlacement.INDENT)
        	                                .addGroup(layout.createParallelGroup()
        	                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                        .addComponent(jLabel2, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                                    .addGroup(layout.createSequentialGroup()
        	                                        .addPreferredGap(jLabel2, jLabel8, LayoutStyle.ComponentPlacement.INDENT)
        	                                        .addGroup(layout.createParallelGroup()
        	                                            .addGroup(layout.createSequentialGroup()
        	                                                .addComponent(jLabel8, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                                .addGap(0, 0, Short.MAX_VALUE))
        	                                            .addGroup(layout.createSequentialGroup()
        	                                                .addGap(8)
        	                                                .addGroup(layout.createParallelGroup()
        	                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                        .addComponent(jLabel5, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
        	                                                    .addGroup(GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
        	                                                        .addGap(47)
        	                                                        .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
        	                                                        .addGap(0, 0, Short.MAX_VALUE)))))))))
        	                        .addGap(391)))))
        	        .addGap(169))));
        cadastra.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                try {
					cadastraMouseClicked(evt);
				} catch (Exception e) {
					
					e.printStackTrace();
				}
            }
        });
       

    }// </editor-fold>

    protected void caixaPosse3KeyReleased(KeyEvent evt) throws Exception {
    	String ano = caixaPosse3.getText();
        if (ano.length() == 4) {
                if (teclaPressionada(evt)) {
                        caixaPosse3.setEditable(true);
                } else {
                        caixaPosse3.setEditable(false);
                }
        }
        anoPosse = ano;
        String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
        try {
                Data dataPosse = new Data(data);
        } catch (Exception e) {
                c7.setForeground(Color.RED);
                c7.setText("Invalido");
                return;
        }
        c7.setForeground(Color.GREEN);
        c7.setText("OK");
        this.dataPosse = new Data(data);
		
	}

	protected void caixaPosse2KeyReleased(KeyEvent evt) throws Exception {
    	String mes = caixaPosse2.getText();
        if (mes.length() == 2) {
                if (teclaPressionada(evt)) {
                        caixaPosse2.setEditable(true);
                } else {
                        caixaPosse2.setEditable(false);
                }
        }
        mesPosse = mes;
        String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
        try {
                Data dataPosse = new Data(data);
        } catch (Exception e) {
                c7.setForeground(Color.RED);
                c7.setText("Invalido");
                return;
        }
        c7.setForeground(Color.GREEN);
        c7.setText("OK");
        this.dataPosse = new Data(data);
		
	}

	protected void caixaAdm3KeyReleased(KeyEvent evt) throws Exception {
    	String ano = caixaAdm3.getText();
        if (ano.length() == 4) {
                if (teclaPressionada(evt)) {
                        caixaAdm3.setEditable(true);
                } else {
                        caixaAdm3.setEditable(false);
                }
        }
        anoAdm = ano;
        String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
        try {
                Data dt = new Data(data);
        } catch (Exception e) {
                c6.setForeground(Color.RED);
                c6.setText("INVALIDO");
                return;
        }
        c6.setForeground(Color.GREEN);
        c6.setText("OK");
        this.dataAdmissao = new Data(data);
		
	}

	protected void caixaAdm2KeyReleased(KeyEvent evt) throws Exception {
    	String mes = caixaAdm2.getText();
        if (mes.length() == 2) {
                if (teclaPressionada(evt)) {
                        caixaAdm2.setEditable(true);
                } else {
                        caixaAdm2.setEditable(false);
                }
        }
        mesAdm = mes;
        String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
        try {
                Data dt = new Data(data);
        } catch (Exception e) {
                c6.setForeground(Color.RED);
                c6.setText("INVALIDO");
                return;
        }
        c6.setForeground(Color.GREEN);
        c6.setText("OK");
        this.dataAdmissao = new Data(data);
		
	}

	private void caixaNomeKeyReleased(java.awt.event.KeyEvent evt) {                                      
        String nome = caixaNome.getText();
        if(!Validadores.validaNome(nome)){
            c1.setText("INVALIDO");
            c1.setForeground(Color.RED);
            flag = false;
        }else{
            
            c1.setText("OK");
            c1.setForeground(Color.GREEN);
        }
        this.nome = nome;
    }
private boolean keyReleased(KeyEvent ke){  
        if ( ke.getKeyCode() == KeyEvent.VK_BACK_SPACE ){
        	return true;
        }
            return false;
    }             

private void caixaCpfKeyReleased(java.awt.event.KeyEvent evt) {
		
        String cpf = caixaCpf.getText();
        if(cpf.length() == 3){
        	if(keyReleased(evt)){
        		caixaCpf.setEditable(true);
        	}else{
        		caixaCpf.setEditable(false);
        	}
        }
        
        this.cpf1 = cpf;
        this.cpf = cpf1+"."+caixaCpf2.getText()+"."+caixaCpf3.getText()+"-"+caixaCpf4.getText();
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
        	c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
        	c2.setText("OK");
        }
}                                    

private void caixaEndKeyReleased(java.awt.event.KeyEvent evt) {                                     
    String end = caixaEnd.getText();
        if(!Validadores.validaEndereco(end)){
            c3.setForeground(Color.RED);
            c3.setText("INVALIDO");
            flag = false;
            return;
        }else{
            c3.setForeground(Color.GREEN);
            c3.setText("OK");

        }
        this.endereco = end;
}                                    

private void caixaTel1KeyReleased(java.awt.event.KeyEvent evt) {                                     
    String tel = caixaTel1.getText();
    if(tel.length() == 2){
    	if(keyReleased(evt)){
    		caixaTel1.setEditable(true);
    	}else{
    		caixaTel1.setEditable(false);
    	}
    }

	telefone1 = tel;
	telefone = "("+telefone1+")"+caixaTel2.getText()+"-"+caixaTel3.getText();
	if(!Validadores.validaTelefone(telefone)){
		c4.setForeground(Color.RED);
		c4.setText("INVALIDO");
	}else{
		c4.setForeground(Color.GREEN);
		c4.setText("OK");
	}
	

}                                    

private void caixaMailKeyReleased(java.awt.event.KeyEvent evt) {                                      
    String mail = caixaMail.getText();
        if(!Validadores.validaEmail(mail)){
            c5.setForeground(Color.RED);
            c5.setText("INVALIDO");
            flag = false;
        }else{
            c5.setForeground(Color.GREEN);
            c5.setText("OK");

        }
        this.email = mail;

}                                     

private void caixaAdmKeyReleased(java.awt.event.KeyEvent evt) throws Exception  {                                     
	String dia = caixaAdm.getText();
	if (dia.length() == 2) {
		if (teclaPressionada(evt)) {
			caixaAdm.setEditable(true);
		} else {
			caixaAdm.setEditable(false);
		}
	}
	diaAdm = dia;
	String data = diaAdm +"/"+ mesAdm +"/"+ anoAdm;
	try {
		Data dt = new Data(data);
	} catch (Exception e) {
		c6.setForeground(Color.RED);
		c6.setText("INVALIDO");
		return;
	}
	c6.setForeground(Color.GREEN);
	c6.setText("OK");
	this.dataAdmissao = new Data(data);
        
}                                    
private boolean teclaPressionada(KeyEvent ke){  
    if ( ke.getKeyCode() == KeyEvent.VK_BACK_SPACE ){
            return true;
    }
        return false;
}
private void caixaPosseKeyReleased(java.awt.event.KeyEvent evt) throws Exception {                                       
	String dia = caixaPosse.getText();
    if (dia.length() == 2) {
            if (teclaPressionada(evt)) {
                    caixaPosse.setEditable(true);
            } else {
                    caixaPosse.setEditable(false);
            }
    }
    diaPosse = dia;
    String data = diaPosse + "/" + mesPosse + "/" + anoPosse;
    try {
            Data dataPosse = new Data(data);
    } catch (Exception e) {
            c7.setForeground(Color.RED);
            c7.setText("Invalido");
            return;
    }
    c7.setForeground(Color.GREEN);
    c7.setText("OK");
    this.dataPosse = new Data(data);
}                                      

                                      

private void caixaFotoKeyReleased(java.awt.event.KeyEvent evt) {                                      
     String caminho = caixaFoto.getText();
        if(!Validadores.validaNome(caminho)){
            c9.setForeground(Color.RED);
            c9.setText("INVALIDO");
            flag = false;
        }else{
            c9.setForeground(Color.GREEN);
            c9.setText("OK");
        }
        this.foto = caminho;
}                                     

private void cancelarMouseClicked(java.awt.event.MouseEvent evt) {                                      
    limparMouseClicked(evt);
    GerenciadorDeJanelas.selecionaFuncionario = new SelecionaFuncionario();
    GerenciadorDeJanelas.window.setContentPane(GerenciadorDeJanelas.selecionaFuncionario);
    GerenciadorDeJanelas.window.setVisible(true);
}                                     

private void limparMouseClicked(java.awt.event.MouseEvent evt) {                                    
	for(Component component: this.getComponents()){
        if(component instanceof JTextField){
            JTextField caixa = (JTextField)component;
            caixa.setEditable(true);
            caixa.setText("");
        }
    }c1.setText("");c2.setText("");c3.setText("");c4.setText("");
    c5.setText("");c6.setText("");c7.setText("");c9.setText("");
    
}                                   

private void cadastraMouseClicked(java.awt.event.MouseEvent evt) throws Exception {
	
	try{
		SelecionaFuncionario.professor.setNome(nome);
	}catch(Exception e){
		
	}
	try{
		SelecionaFuncionario.professor.setEndereco(endereco);
	}catch(Exception e){
		
	}try{
		SelecionaFuncionario.professor.setCpf(cpf);
	}catch(Exception e){
		
	}try{
		SelecionaFuncionario.professor.setTelefone(telefone);
	}catch(Exception e){
		
	}try{
		SelecionaFuncionario.professor.setEmail(email);
	}catch(Exception e){
		
	}try{
		SelecionaFuncionario.professor.setDataAdmissao(dataAdmissao);
	}catch(Exception e){
		
	}try{
		SelecionaFuncionario.professor.setDataPosse(dataPosse);
	}catch(Exception e){
		
		
	}try{
		SelecionaFuncionario.professor.setFoto(foto);
	}catch(Exception e){
		
	}
	for(Component component: this.getComponents()){
        if(component instanceof JLabel){
        	if(component.getForeground().equals(Color.RED)){
        		JOptionPane.showMessageDialog(null,"Algum dado invalido");
        		return;
        	}
        }
        	
	}
	
   for(int i = 0; i < GerenciadorDeJanelas.todosProfessores.size(); i++){
	   if(GerenciadorDeJanelas.todosProfessores.get(i).getMatricula() == SelecionaFuncionario.professor.getMatricula()){
		   GerenciadorDeJanelas.todosProfessores.remove(i);
		   GerenciadorDeJanelas.todosProfessores.add(SelecionaFuncionario.professor);
	   }
   }
// transforma em xml
   String xmlProfessor = GerenciadorDeJanelas.ARQUIVADOR
	.toXML(GerenciadorDeJanelas.todosProfessores);
// grava o arrayXml no arquivo
	GerenciadorDeJanelas.gravar(GerenciadorDeJanelas.arquivoDeProfessores,
			xmlProfessor);
   
    limparMouseClicked(evt);
    SelecionaFuncionario selecF = new SelecionaFuncionario();
    GerenciadorDeJanelas.window.setContentPane(selecF);
    GerenciadorDeJanelas.window.setVisible(true);
    
	
}                                    

	private void caixaCpf2KeyReleased(KeyEvent evt) {

        String cpf = caixaCpf2.getText();
        if(cpf.length() == 3){
        	if(keyReleased(evt)){
        		caixaCpf2.setEditable(true);
        	}else{
        		caixaCpf2.setEditable(false);
        	}
        }
        this.cpf2 = cpf;
        this.cpf = caixaCpf.getText()+"."+cpf2+"."+caixaCpf3.getText()+"-"+caixaCpf4.getText();
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
        	c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
        	c2.setText("OK");
        }
	}
	
	private void caixaCpf3KeyReleased(KeyEvent evt) {

        String cpf = caixaCpf3.getText();
        if(cpf.length() == 3){
        	if(keyReleased(evt)){
        		caixaCpf3.setEditable(true);
        	}else{
        		caixaCpf3.setEditable(false);
        	}
        }
        this.cpf3 = cpf;
        this.cpf = caixaCpf.getText()+"."+caixaCpf2.getText()+"."+cpf3+"-"+caixaCpf4.getText();
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
        	c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
        	c2.setText("OK");
        }
	}
	
	private void caixaCpf4KeyReleased(KeyEvent evt) {

        String cpf = caixaCpf4.getText();
        if(cpf.length() == 2){
        	if(keyReleased(evt)){
        		caixaCpf4.setEditable(true);
        	}else{
        		caixaCpf4.setEditable(false);
        	}
        }


        this.cpf4 = cpf;
        this.cpf = caixaCpf.getText()+"."+caixaCpf2.getText()+"."+caixaCpf3.getText()+"-"+cpf4;
        if(!Validadores.validaCpf(this.cpf)){
        	c2.setForeground(Color.RED);
            c2.setText("INVALIDO");
        }else{
        	c2.setForeground(Color.GREEN);
            c2.setText("OK");
        }
	}
	
	private void caixaTel2KeyReleased(KeyEvent evt) {
		String tel = caixaTel2.getText();
		if(tel.length() == 4){
        	if(keyReleased(evt)){
        		caixaTel2.setEditable(true);
        	}else{
        		caixaTel2.setEditable(false);
        	}
        }
		
	        this.telefone2 = tel;
	        telefone = "("+caixaTel1.getText()+")"+tel+"-"+caixaTel3.getText();
	    	if(!Validadores.validaTelefone(telefone)){
	    		c4.setForeground(Color.RED);
	    		c4.setText("INVALIDO");
	    	}else{
	    		c4.setForeground(Color.GREEN);
	    		c4.setText("OK");
	    	}
	        
	}
	
	private void caixaTel3KeyReleased(KeyEvent evt) {
		String tel = caixaTel3.getText();
		if(tel.length() == 4){
        	if(keyReleased(evt)){
        		caixaTel3.setEditable(true);
        	}else{
        		caixaTel3.setEditable(false);
        	}
        }
		if(tel.length() == 4){
			c4.setForeground(Color.GREEN);
	        c4.setText("OK");
	        
		}else{
			c4.setForeground(Color.RED);
	        c4.setText("INVALIDO");
	        return;
		}
	        this.telefone3 = tel;
	        telefone = "("+caixaTel1.getText()+")"+caixaTel2.getText()+"-"+telefone3;
	        if(!Validadores.validaTelefone(telefone)){
	        	caixaTel3.setBackground(Color.RED);
		        c4.setText("INVALIDO");
	        }else{
	        	c4.setForeground(Color.GREEN);
		        c4.setText("OK");
	        }
	}
	


}
